package com.cdcas;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/login")
public class login extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       //获取jsp传递过来的参数
        String uname =   req.getParameter("username");
       String upassword= req.getParameter("password");
       //从数据中根据用户名和密码查询数据

        if (uname !=null && uname.length()>0 && upassword !=null && upassword.length() >0) {

            System.out.println("用户名：" + uname + "密码：" + upassword);
            resp.sendRedirect("register.jsp");
        }


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
